#编写一个装饰器，能计算其他函数的运行时间；


import time

def test(func):
    def inner():
        print(func)
        start=time.time()
        func()
        end=time.time()
        print("运行时间%s"%(end-start))
    return inner

@test
def foo():
    time.sleep(2)
    print("你好")
foo()

# import time
# from datetime import datetime

# def timer( func ):
#     def inner():
#         # start_time = time.time()
#         start_time = datetime.now()
#         func()
#         # end_time = time.time()
#         end_time = datetime.now()
#         time_difference = end_time - start_time
#         print( 'Processing time of function %s is %s' %( func.__name__, time_difference ) )
#     return inner

# @timer
# def test_func():
#     print( 'Hi there, this is the test function' )

# test_func()